/*
 *  Game.h
 *  SpaceTrader
 *
 *  This class offers many of the essential methods for interacting with the GUI/View component.
 *
 */
#pragma once
#include "SDL/SDL.h"
#ifdef __APPLE__
	#include "SDL_image/SDL_image.h"
	#include "SDL_ttf/SDL_ttf.h"
#else	//linux support
	#include "SDL/SDL_image.h"
	#include "SDL/SDL_ttf.h"
#endif
#include <string>
#include <vector>

void apply_surface(int x, int y, SDL_Surface *source, SDL_Surface *destination);

void apply_surface_clip( int x, int y, SDL_Rect clip, SDL_Surface *source, SDL_Surface *destination);

bool check_collision(SDL_Rect A, SDL_Rect B );

void showParagraph(int x, int y, std::string msg, int lineLength, TTF_Font *font, SDL_Surface *screen);

/*
 * Displays a pop-up lightbox with an OK button and a short message.
 */
void showPopUpWithMessage(std::string msg, SDL_Surface *screen);

std::string showLoginDialog(SDL_Surface *screen);

std::vector<std::string> parseStringIntoLines(std::string msg, int charWidth);

SDL_Surface *load_image(std::string filename, bool colorKey );

TTF_Font *getFont(std::string s);

void clean_up();

/*
 * Creates a table that can be used to neatly display data to the user. It's messy right now, but the
 * current order of initialization is...
 * (1) Instantiate the GuiTable.
 * (2) Create a char** of the strings to place in the table, starting at the top-left cell going down, and then the next column, etc.
 * (3) Call table.setContents() and pass in that array.
 */
class GuiTable {
	
private:
	int rows;
    int cols;
	int x, y;
    int w, h;
    std::vector<std::vector<SDL_Surface*> > table;
    
    TTF_Font *stdFont;
	SDL_Color white;

    
public:
    GuiTable(int cols, int rows, int x, int y, int width, int height, int fontSize);
	GuiTable(const GuiTable &G);
	~GuiTable();
    GuiTable& operator=(const GuiTable &G);
    /*
     * Table is as such:
     * A D G
     * B E H
     * C F I  .
     * The contents are assumed in the array to be in the order {A, B, C, D, E, F, G, H, I}.
     */
    void setContents(const char **contents);
	
	void setContents(std::vector<std::string> contents);

    void show(SDL_Surface *screen);
    
    void setCoords(int x, int y);
	
	void setX(int x);
	
	void setY(int y);
    
    /*
     * Calculates total width of the table, can be used for alignment.
     */
    int getTotalWidth();
};
